﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business;
using DTO;

namespace Airplane
{
    public partial class DangKy : System.Web.UI.Page
    {
        private KhachHang khachHang = new KhachHang();
        private int SoThe;
        private XuLyThemKhachHang themKhachHang = new XuLyThemKhachHang();
        public KhachHang KhachHang
        {
            get { return khachHang; }
            set { khachHang = value; }
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            
            MultiViewDangKy.ActiveViewIndex = 0;
        }

        
        protected void CalendarNgaySinh_SelectionChanged(object sender, EventArgs e)
        {
            
        }
        public void DangKyThanhVien()
        {
            KhachHang.HoTen = txtHoTen.Text;
            if (rdbNu.Checked)
                khachHang.GioiTinh = "Nu";
            else
            {
                KhachHang.GioiTinh = "Nam";
            }
            KhachHang.DiaChi = txtDiaChi.Text;
            KhachHang.NgaySinh =Convert.ToDateTime( txtNgaySinh.Text);
            KhachHang.Email = txtemail.Text;
            KhachHang.DienThoai = txtDienThoai.Text;
            KhachHang.SoGiayToTuyThan = txtSoGiayToTuyThan.Text;
            KhachHang.LoaiGiayToTuyThan = ddlGiayTo.SelectedValue.ToString();
            KhachHang.NgayCap = Convert.ToDateTime(txtNgayCap.Text);
            KhachHang.QuocTich = txtQuocTich.Text;
            KhachHang.NuocPhatHanh = txtNuocPhatHanh.Text;
            KhachHang.TenTaiKhoan = txtTenTaiKhoan.Text;
            KhachHang.MatKhau = txtMatKhau.Text;
            KhachHang.EmailPhucHoi = txtEmailPhucHoi.Text;
            KhachHang.SoDam = 0;
            KhachHang.HangHoiVien = 1;
            KhachHang.SoCreditCard = txtCredit.Text;
            khachHang.LoaiCreditCard = txtLoaiCredit.Text;
            KhachHang.NgayHetHanCredit = Convert.ToDateTime(txtNgayHetHan.Text);
            themKhachHang.khachhang = this.KhachHang;
           SoThe= themKhachHang.ThucThi();
        }

        protected void btnDangKy_Click(object sender, EventArgs e)
        {
            try
            {
                DangKyThanhVien();
                MultiViewDangKy.ActiveViewIndex = 1;
                lbSoThe.Text += "Số thẻ thảnh viên của quí khách là: " + SoThe;
            }
            catch (Exception ex)
            {
                lbDangKy.Text = ex.Message;
            }
        }
    }
}